class B {
    public int func() {//方法名要小写
        System.out.print("B");
        return 0;
    }
}
class D extends B {
    @Override
    public int func() {//重写父类的func方法
        System.out.print("D");
        return 0;
    }
}
public class Test {
    public static void main(String[] args) {
        B a = new B();
        B b = new D();//父类引用去引用一个子类对象
        a.func();
        b.func();//发生动态绑定
    }
}
